package com.example.maili.woxiamg.base;

import android.app.Activity;
import android.content.pm.ActivityInfo;
import android.os.Bundle;
import android.support.v4.app.FragmentActivity;
import android.view.View;
import android.view.Window;

/**
 * Created by Administrator on 2016/12/6.
 */

public abstract class BaseActivity extends FragmentActivity implements View.OnClickListener {

    public Activity context;


    @Override
    public void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        context = this;
        setRequestedOrientation(ActivityInfo.SCREEN_ORIENTATION_PORTRAIT);//竖屏
        requestWindowFeature(Window.FEATURE_NO_TITLE);
//        MyApplication.getInstance().addActivity(this);

        initView();

//        View ll_fanhui = findViewById(R.id.ll_fanhui);
//        if (ll_fanhui != null)
//            ll_fanhui.setOnClickListener(this);

        initdata();

    }

    @Override
    protected void onResume() {
        super.onResume();
    }
    /**
     * 初始化view
     */
    public abstract void initView();


    /**
     * 初始化数据
     */
    public abstract void initdata();

    @Override
    protected void onDestroy() {
//        MyApplication.getInstance().removeActivity(this);
        super.onDestroy();

    }

    /**
     * 设置点击事件
     */
    @Override
    public void onClick(View v) {
        switch (v.getId()) {
//            case R.id.ll_fanhui:
//                finish();
//                break;
            default:
                onClickListener(v);
                break;
        }
    }

    /**
     * 重写点击事件，重写时删除suoer；
     */
    protected void onClickListener(View view) {
        throw new UnsupportedOperationException("请重写onClickListener(View view)");
    }
}
